import { CDMissionTrial } from "../excel/CDMissionTrial";
import { Player } from "../struct/Player";
import { SDMission } from "./SDMission";


/**
 * 数据-新兵试炼任务
 */
export abstract class SDTrialMission {


    /**
     * 任务已全部完成
     * @param player 
     * @param trial 
     * @returns -1-未完成，0-已完成，>0-未完成的任务id
     */
    public static checkMissionAllComplete(
        player: Player,
        trial: number | CDMissionTrial,
        nowTime: number
    ): number {
        if (typeof (trial) === 'number') {
            trial = CDMissionTrial.getData(trial);
        }
        if (!trial) {
            return -1;
        }
        const list = trial.missionId;
        for (let i = 0, len = list.length; i < len; i++) {
            if (!SDMission.isMissionComplete(player, list[i], nowTime)) {
                return list[i];
            }
        }

        return 0;
    }


    /**
     * 新兵试炼任务-奖励是否已领取
     * @param player 
     * @param trialId 
     * @returns 
     */
    public static isRewardGetted(player: Player, trialId: number): boolean {
        const status = player.mission.getTrialStatus(trialId);
        if (status && status.isGetReward) {
            return true;
        }
        return false;
    }



}
